package com.ihg.hiex.admin.web.controller.session.during;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.demo2do.core.web.interceptor.MenuSetting;
import com.ihg.hiex.admin.service.account.DelegateService;
import com.ihg.hiex.admin.service.session.SessionFinanceManagementService;
import com.ihg.hiex.admin.service.session.SessionService;
import com.ihg.hiex.entity.session.Session;
import com.ihg.hiex.entity.session.during.SessionFinanceManagement;
import com.ihg.hiex.entity.user.Delegate;

/**
 * 总经理汇报
 * 
 * @author Sanz
 *
 */
@Controller
@RequestMapping("/sessions/{sessionId}")
@MenuSetting("menu-assessment-day")
public class GMMeetingController {
    
    @Autowired
    private SessionService sessionService;
    
    @Autowired
    private DelegateService delegateService;
    
    @Autowired
    private SessionFinanceManagementService sessionFinanceManagementService;
    
    /**
     * 
     * @param sessionId
     * @param delegateId
     * @return
     */
    @RequestMapping(path = "/gm-meetings/finance-management-analysis", method = RequestMethod.GET)
    public ModelAndView financeAnalysis(@PathVariable("sessionId") Long sessionId,
                                        @RequestParam("delegate") Long delegateId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/gm-meeting/preparation/financial-management-analysis");
        
        Session session = sessionService.load(sessionId);
        Delegate delegate = delegateService.load(Delegate.class, delegateId);
        
        // load fininanceManagement
        SessionFinanceManagement sessionFinanceManagement = sessionFinanceManagementService.load(session, delegate);
        modelAndView.addObject("sessionFinanceManagement", sessionFinanceManagement);
        
        modelAndView.addObject("session", session);
        
        return modelAndView;
        
    }
    
}